home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Wipes ƒ / Random wipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.4 KB  |  51 lines  |  [TEXT/MMCC]

  1. #include "timing.h"
  2.  
  3. #define        SUB_HOR        20
  4. #define        SUB_VER        20
  5. #define        AREA        (SUB_HOR * SUB_VER)
  6. #define CorrectTime 1
  7. #define theWindowWidth (boundsRect.right-boundsRect.left)
  8. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  9.  
  10. pascal short RandomWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  11.  
  12. /* Basically, we divide the window into a bunch of blocks, and copy
  13. each to the screen in random order. */
  14. pascal short RandomWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  15. {
  16.     short            order[AREA];
  17.     short            i;
  18.     long            randtemp;
  19.     short            ordertemp;
  20.     Rect            subBox;
  21.     Boolean            everyOther;
  22.     
  23.     everyOther=FALSE;
  24.     for(i = 0; i < AREA; i++)
  25.         order[i] = i;
  26.     
  27.     for(i = (AREA - 1); i >= 0; i--) {
  28.         randtemp = ((((long)Random()) +32767) * (i + 1)) / 65535;
  29.         
  30.         ordertemp = order[randtemp];
  31.         order[randtemp] = order[i];
  32.         order[i] = ordertemp;
  33.     }
  34.     
  35.     for(i = 0; i < AREA; i++) {
  36.         StartTiming();
  37.         subBox.top = ((order[i] / SUB_VER) * theWindowHeight) / SUB_VER;
  38.         subBox.left = ((order[i] % SUB_HOR) * theWindowWidth) / SUB_HOR;
  39.         subBox.bottom = (((order[i] / SUB_VER) + 1) * theWindowHeight) / SUB_VER;
  40.         subBox.right = (((order[i] % SUB_HOR) + 1) * theWindowWidth) / SUB_HOR;
  41.         OffsetRect(&subBox, boundsRect.left, boundsRect.top);
  42.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  43.             &subBox, &subBox, 0, 0L);
  44.         if (everyOther)
  45.             TimeCorrection(CorrectTime);
  46.         everyOther=!everyOther;
  47.     }
  48.     
  49.     return 0;
  50. }
  51.